package serverRMI;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

public class PilhaRemota extends UnicastRemoteObject implements IPilha {
	
	int [] elements;
	int top = -1;
	int max = 0;
		
	public PilhaRemota(int max) throws RemoteException {
		
		elements = new int [max];
		this.max = max;
	}

	@Override
	public int pop() throws RemoteException {
		if (this.top >= 0){
			int x = this.elements[this.top];
			this.top--;
			return x;
		}
		return -999;
	}

	@Override
	public void push(int x) throws RemoteException {
		if (this.top < this.max - 1){
			this.top++;
			this.elements[top] = x;
		}
	}

}
